package commands

import (
	"github.com/spf13/cobra"
	client "github.com/yourusername/lvm-manager/pkg/client"
)

// getAPIClient retrieves the API URL from the root command's persistent flags and returns a client.
func getAPIClient(cmd *cobra.Command) *client.Client {
	root := cmd.Root()
	apiURL, err := root.PersistentFlags().GetString("api")
	if err != nil {
		return nil
	}
	return client.NewClient(apiURL)
}
